<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <style>
        div{
            width: 200px;
            height: 200px;
        }
        .box{
            border-radius: 50%;
        }
        .red{
            background-color: rgb(250, 23, 23);
        }
        .blue{
            background-color: blue;
        }
    </style>
</head>
<body>
    <div class="red box"></div>
    
</body>
<script>
   var  div=document.querySelector('div')
   div.addEventListener('click',function(){
      //通过class属性修改 
  //  div.className='box blue '  不方便 很容易遗漏一些样式
      this.classList.remove('red')
      this.classList.add('blue')
       

       //通过style属性修改背景色
   })
</script>
</html>